package com.powergisol.core.model;

import com.vividsolutions.jts.geom.Coordinate;

public  class PointWithIndex {

    private int index;

    private Double x;

    private Double y;

    private Double z;

    private PointWithIndex next;
    /**
     * 顶点所对的边
     */
    private Edge edge;


    public PointWithIndex(Coordinate coordinate, int index) {
        this.x = coordinate.x;
        this.y = coordinate.y;
        this.z = coordinate.z;
        this.index = index;
    }

    public void setNext(PointWithIndex next) {
        this.next = next;
    }

    public PointWithIndex getNext() {
        return next;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Double getX() {
        return x;
    }

    public void setX(Double x) {
        this.x = x;
    }

    public Double getY() {
        return y;
    }

    public void setY(Double y) {
        this.y = y;
    }

    public Double getZ() {
        return z;
    }

    public void setZ(Double z) {
        this.z = z;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PointWithIndex that = (PointWithIndex) o;

        if (index != that.index) return false;
        if (!x.equals(that.x)) return false;
        if (!y.equals(that.y)) return false;
        if (!z.equals(that.z)) return false;
        if (!next.equals(that.next)) return false;
        return edge.equals(that.edge);
    }

    @Override
    public int hashCode() {
        int result = index;
        result = 31 * result + x.hashCode();
        result = 31 * result + y.hashCode();
        result = 31 * result + z.hashCode();
        result = 31 * result + next.hashCode();
        result = 31 * result + edge.hashCode();
        return result;
    }

    public Coordinate getCoordinate() {
        return new Coordinate(this.x, this.y, this.z);
    }

    public void setEdge(Edge edge) {
        this.edge = edge;
    }

    public Edge getEdge() {
        return edge;
    }

    @Override
    public String toString() {
        return "PointWithIndex{" +
                "index=" + index +
                ", x=" + x +
                ", y=" + y +
                ", z=" + z +
                '}';
    }
}
